﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Threading;

namespace HuiZe.education.View.Ethan
{
    /// <summary>
    /// PART_Media_Image_List_.xaml 的交互逻辑
    /// </summary>
    public partial class PART_Media_Images : Grid
    {
        public PART_Media_Images()
        {
            InitializeComponent();
        }

        public void SetImageList(string[] _images, int _seconds, double _w, double _h)
        {
            if (_images == null || _images.Length == 0)
            {
                Reset();
                return;
            }

            var _carousel = new education.Ethan.Carousel
            {
                Width = _w,
                Height = _h,
                AutoPlay = false,
                AutoPlaySpeed = _seconds * 1000,
                VerticalAlignment = VerticalAlignment.Stretch,
                VerticalContentAlignment = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                ItemTemplate = (DataTemplate)this.PART_Host.FindResource("ImageItemTemplate"),
            };
            _carousel.ItemsSource = _images;
            PART_Host.Children.Add(_carousel);
        }

        public void Reset()
        {
            PART_Host.Children.Clear();
        }
    }
}
